<template>
  <el-menu
    :default-active="activeIndex"
    mode="horizontal"
    :router="true"
    @select="handleSelect"
  >
    <el-menu-item index="order" v-if="userStore.scene_only_query!='1'">出票</el-menu-item>    
    <el-menu-item index="list" v-if="userStore.scene_only_query!='1'">订单列表</el-menu-item>
    <el-menu-item index="search" v-if="userStore.scene_only_query!='1'">查询订单</el-menu-item>
    <el-menu-item index="onlysearch" v-if="userStore.scene_only_query=='1'">查询订单</el-menu-item>
    <el-dropdown class="user">
      <span>
        {{ userStore.userName }}
        <el-icon>
          <arrow-down />
        </el-icon>
      </span>
      <template #dropdown>
        <el-dropdown-menu> 
          <el-dropdown-item @click="logout">退出登录</el-dropdown-item>
        </el-dropdown-menu>
      </template>
    </el-dropdown>
  </el-menu>
  
</template>

<script setup>
import { ref } from 'vue'
import {useRouter} from 'vue-router'
import { useUser } from "@/stores/user";
import { ArrowDown } from '@element-plus/icons-vue'
const userStore = useUser();
const props = defineProps(['page'])
const activeIndex = ref(props.page)
const router = useRouter() 
const handleSelect = (key, keyPath) => {
  router.push({
    name:key
  })
}
const logout = ()=>{
  userStore.handleLogout()
}
</script>

<style scoped>
.user{
    position: absolute;
    top:20px;
    right: 20px;
  }
</style>